import json
import sys
import traceback

from rediscluster import StrictRedisCluster


def redis_cluster():
    host = '10.78.115.124'
    redis_nodes = [{'host': host, 'port': 6400},
                   {'host': host, 'port': 6401},
                   {'host': host, 'port': 6402},
                   {'host': host, 'port': 6403},
                   {'host': host, 'port': 6404},
                   {'host': host, 'port': 6405}
                   ]
    try:
        redisconn = StrictRedisCluster(startup_nodes=redis_nodes)
        redisconn.set("key", "value")
        json.dumps(redisconn.get("key"))
        while True:
            print(redisconn.get("key"))
    except:
        traceback.print_exc()
        sys.exit(1)


if __name__ == '__main__':
    redis_cluster()
